#include <cstdio>
#include <cstring>
#include <cmath>
#define PR_LIM 1000000
//Eratosthenes
bool isprime[PR_LIM];

void Eraos() {
	int i, j, sq = (int)ceil(sqrt(PR_LIM));
	memset(isprime, 1, sizeof(isprime));
	isprime[0] = isprime[1] = 0;
	for (i = 2; i < sq; i++)
		for (j = i + i; isprime[i] && j < PR_LIM; j += i)
			isprime[j] = 0;
}

int main() {
	int a, b, n, k, i;
	Eraos();
	while (scanf("%d%d%d", &a, &b, &n) && (a || b || n)) {
		for (i = 0, k = a; i < n; k += b)
			if (isprime[k]) i++;
		printf("%d\n", k - b);
	}
	return 0;
}
